function prfmstats(opts, di, ci)
fprintf('regvals:\n');
fprintf('    %.4f', opts.regvals(ci));
fprintf('\niters:\n');
if isfield(opts, 'errs')
    vals = opts.errs;
    mvals = opts.merr;
    if isfield(opts, 'mferr')
        mfvals = opts.mferr;
    end
    valname = 'nmae';
    statfun = @(x)min(x, [], 2);
elseif isfield(opts, 'accu')
    vals = opts.accu;
    mvals = opts.macc;
    valname = 'accu';
    statfun = @(x)max(x, [], 2);
elseif isfield(opts, 'pexvar')
    vals = opts.pexvar;
    mvals = opts.mpexvar;
    valname = 'pexvar';
    statfun = @(x)max(x, [], 2);
else
    warning('Lacking necessary performance statistics!');
end
[endvals, iters, statvals] = iterstats(vals(di,ci), 1, statfun);
fprintf('      %2d', round(mean(iters(:,1), 1)));
fprintf('        %2d', round(mean(iters(:,2:end), 1)));
fprintf(['\nmean(' valname '):\n']);
fprintf('    %.4f', mean(endvals, 1));
fprintf('\n');
fprintf('    %.4f', mean(statvals, 1));
pause
if opts.algtype ~= 2 % not EM
    [endvals, ~, statvals] = iterstats(mvals(di,ci), 1, statfun);
    fprintf(['\nmean(m' valname '):\n']);
    fprintf('    %.4f', mean(endvals, 1));
    fprintf('\n');
    fprintf('    %.4f', mean(statvals, 1));
    pause
    if exist('mfvals', 'var')
        [endvals, ~, statvals] = iterstats(mfvals(di,ci), 1, statfun);
        fprintf(['\nmean(mf' valname '):\n']);
        fprintf('    %.4f', mean(endvals, 1));
        fprintf('\n');
        fprintf('    %.4f', mean(statvals, 1));
        pause
    end
end
if isfield(opts, 'aucs')
    [endvals, ~, maxvals] = iterstats(opts.aucs(di,ci), 1, @(x)max(x, [], 2));
    fprintf('\nmean(aucs):\n');
    fprintf('    %.4f', mean(endvals, 1));
    fprintf('\n');
    fprintf('    %.4f', mean(maxvals, 1));
    pause
    if opts.algtype ~= 2 % not EM
        [endvals, ~, maxvals] = iterstats(opts.mauc(di,ci), 1, @(x)max(x, [], 2));
        fprintf('\nmean(mauc):\n');
        fprintf('    %.4f', mean(endvals, 1));
        fprintf('\n');
        fprintf('    %.4f', mean(maxvals, 1));
        pause
    end
end
[endvals, ~, minvals] = iterstats(opts.fvals(di,ci), 1);
fprintf('\nmean(fval): 1e6\n');
fprintf('    %.4f', mean(endvals./1e6, 1));
fprintf('\n');
fprintf('    %.4f', mean(minvals./1e6, 1));
pause
if opts.algtype ~= 2 % not EM
    [endvals, ~, minvals] = iterstats(opts.mfval(di,ci), 1);
    fprintf('\nmean(mfval): 1e6\n');
    fprintf('    %.4f', mean(endvals./1e6, 1));
    fprintf('\n');
    fprintf('    %.4f', mean(minvals./1e6, 1));
    pause
end
if isfield(opts, 'etimes')
    [~, ~, totime] = iterstats(opts.etimes(di,ci), 1, @(x)sum(x));
    fprintf('\nmean(totime): (s)\n');
    fprintf('    %.4f', mean(totime, 1));
    pause
end
if isfield(opts, 'postdim')
    [endvals, ~, inivals] = iterstats(opts.postdim(di,ci), 1, @(x)x(1));
    fprintf('\nmean(postdim):\n');
    fprintf('     %4d', round(mean(endvals(:,1), 1)));
    fprintf('      %4d', round(mean(endvals(:,2:end), 1)));
    fprintf('\n');
    fprintf('     %4d', round(mean(inivals(:,1), 1)));
    fprintf('      %4d', round(mean(inivals(:,2:end), 1)));
    fprintf('\n');
    pause
end
fprintf('\n');

[~, optcid] = statfun(mean(statvals, 1));
maxiter = max(iters(:,optcid));
optcid = ci(optcid);
figure;
plot(cell2mat(cellfun(@(x)[x,nan*ones(1,maxiter-numel(x))], opts.fvals(di,optcid), 'UniformOutput', false))', ...
    '*--', 'LineWidth', 1.5);
hold on;
if opts.algtype ~= 2 % not EM
    plot(cell2mat(cellfun(@(x)[x,nan*ones(1,maxiter-numel(x))], opts.mfval(di,optcid), 'UniformOutput', false))', ...
        '.-', 'LineWidth', 1.5);
end
pause
figure;
plot(cell2mat(cellfun(@(x)[x(1,:),nan*ones(1,maxiter-size(x,2))], vals(di,optcid), 'UniformOutput', false))', ...
    '*--', 'LineWidth', 1.5);
hold on;
if opts.algtype ~= 2 % not EM
    plot(cell2mat(cellfun(@(x)[x(1,:),nan*ones(1,maxiter-size(x,2))], mvals(di,optcid), 'UniformOutput', false))', ...
        '.-', 'LineWidth', 1.5);
    if exist('mfvals', 'var')
        plot(cell2mat(cellfun(@(x)[x(1,:),nan*ones(1,maxiter-size(x,2))], mfvals(di,optcid), 'UniformOutput', false))', ...
            '+:', 'LineWidth', 1.5);
    end
end
pause

close all

end